package com.groupbuying.customer.service.impl;

import com.groupbuying.customer.dao.CustomerShopLevelDao;
import com.groupbuying.customer.domain.CustomerShopLevelDO;
import com.groupbuying.customer.domain.CustomerShopLevelTypeDO;
import com.groupbuying.customer.service.CustomerShopLevelService;
import com.groupbuying.customer.service.CustomerShopLevelTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class CustomerShopLevelServiceImpl implements CustomerShopLevelService {
    @Autowired
    private CustomerShopLevelDao customerShopLevelDao;
    @Autowired
    private CustomerShopLevelTypeService customerShopLevelTypeService;


    @Override
    public CustomerShopLevelDO get(String uuid) {
        return customerShopLevelDao.get(uuid);
    }

    @Override
    public List<CustomerShopLevelDO> list(Map<String, Object> map) {
        return customerShopLevelDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return customerShopLevelDao.count(map);
    }

    @Override
    public int save(CustomerShopLevelDO customerShopLevel) {
        return customerShopLevelDao.save(customerShopLevel);
    }

    @Override
    public int update(CustomerShopLevelDO customerShopLevel) {
        return customerShopLevelDao.update(customerShopLevel);
    }

    @Override
    public int remove(String uuid) {
        return customerShopLevelDao.remove(uuid);
    }

    @Override
    public int batchRemove(String[] uuids) {
        return customerShopLevelDao.batchRemove(uuids);
    }

    @Override
    public String getInitLevelUuid() {
        CustomerShopLevelTypeDO csltm = (CustomerShopLevelTypeDO) customerShopLevelTypeService.getUseShopType();
        if (csltm != null) {
            Map map = new HashMap();
            map.put("delflag", "1");
            map.put("leveltypeuuid", csltm.getUuid());
            List<CustomerShopLevelTypeDO> list = this.list(map);
            if (list != null) {
                return list.size()>0? list.get(0).getUuid(): "";
            }
        }
        return "";
    }


}
